package rpc.client;

import java.lang.reflect.Proxy;

public class ClientProxyUtil {

    public static Object getProxyInstance(Class<?> cls) {
        if (!cls.isInterface())
            throw new IllegalArgumentException("代理类型非接口类型 cls = " + cls);
        Class<?>[] Interfaces = new Class[]{cls};
        Object proxyInstance = Proxy.newProxyInstance(cls.getClassLoader(),
                Interfaces, ClientProxy.getClientProxy());
        return proxyInstance;
    }

}
